package com.qf.bootdaily.utils;

import lombok.Data;

@Data
public class Response <T>{
    private Integer code;
    private String msg;
    private T data;

    public Response(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Response<T> success(Integer code, String msg, T data){
        return new Response<>(code, msg, data);
    }

    public static <T> Response<T> success(T data){
        return success(0,"成功",data);
    }
    public static <T> Response<T> success(){
        return success(null);
    }


    public static <T> Response<T> fail(Integer code, String msg, T data){
        return new Response<>(code, msg, data);
    }

    public static <T> Response<T> fail(T data){
        return fail(-1,"失败",data);
    }
    public static <T> Response<T> fail(){
        return fail(null);
    }
}
